package com.example.fitapp.activity.fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.fitapp.activity.R;
import com.example.fitapp.activity.bean.QuestionInfo;

public class CardFragment extends Fragment {

    private View mRootView;
    private TextView contentTitle;
    private TextView tv_option1;
    private ImageView img_option1;
    private TextView tv_option2;
    private ImageView img_option2;

    private QuestionInfo mCurrentInfo;

//    通过Bundle传递
    public static CardFragment newInsrance(QuestionInfo info){
        CardFragment fragment = new CardFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("info",info);
        fragment.setArguments(bundle);
        return fragment;
    };

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mRootView = inflater.inflate(R.layout.fragment_layout,container, false);
        return mRootView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
        mCurrentInfo =(QuestionInfo) getArguments().getSerializable("info");
        contentTitle.setText(mCurrentInfo.title);
    }

    private void initView(){
        contentTitle = mRootView.findViewById(R.id.contentTitle);
        tv_option1 = mRootView.findViewById(R.id.tv_option1);
        tv_option2 = mRootView.findViewById(R.id.tv_option2);
        img_option1 = mRootView.findViewById(R.id.img_option1);
        img_option2 = mRootView.findViewById(R.id.img_option2);
    }
}
